{include file="public/head" /}

<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">后台管理</a>
        <a href="">物业管理系统</a>
        <a>
          <cite>发票列表</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so"  method="get" action="{url('invoiceList')}">

            <div class="layui-input-inline">
                <select name="community_id" lay-filter="community_id" id="community_id">
                    <option value="">所属小区</option>
                    {foreach $communitylist as $name}
                    <option value="{$name.community_id}" {if isset($community_id)}{if $community_id == $name.community_id}selected{/if}{/if}>{$name.community_name}</option>
                    {/foreach}
                </select>
            </div>


            <div class="layui-input-inline">
                <select name="invoice_type">
                    <option value="">发票类型</option>
                    <option value="1" {if isset($invoice_type)}{if $invoice_type == '1'}selected{/if}{/if}>蓝票</option>
                    <option value="2" {if isset($invoice_type)}{if $invoice_type == '2'}selected{/if}{/if}>红票</option>

                </select>
            </div>
            <div class="layui-input-inline">
                <input type="text" name="owner_name"  placeholder="业主姓名" autocomplete="off" class="layui-input" value="{if isset($owner_name)}{$owner_name}{/if}">
            </div>
             <div class="layui-input-inline">
                <input type="text" name="owner_phone"  placeholder="业主电话" autocomplete="off" class="layui-input" value="{if isset($owner_phone)}{$owner_phone}{/if}">
             </div>
            <div class="layui-input-inline" >
                <input class="layui-input" placeholder="开始时间" name="start_time" id="start" {if isset($start_time)}value="{$start_time}"{/if} >
            </div>
            <div class="layui-input-inline" >
                <input class="layui-input" placeholder="结束时间" name="end_time" id="end" {if isset($end_time)}value="{$end_time}"{/if} >
            </div>
            <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
    </div>
    <xblock>

        <button class="layui-btn" onclick="invoiceExportExcel('{$export}','{$exportb}')"><i class="layui-icon"></i>批量导出</button>
        <span style="color:red"> *缴费完成自动推送到缴费手机支付宝首页'卡包'中，5分钟后可以查看。</span>

        {if $Think.session.usertype=="0"}

        {/if}
        <span class="x-right" style="line-height:40px">&nbsp; 共有数据： {$number}  条</span>
    </xblock>
    <table class="layui-table"  id="table">
        <thead>
        <tr>
            {if $Think.session.usertype=="0"}
            <th style="text-align: center; font-size: 16px;">pay_id</th>
            {/if}
            <th style="text-align: center; font-size: 16px;">小区名称</th>
            <th style="text-align: center; font-size: 16px;">发票抬头/业主房号</th>
            <th style="text-align: center; font-size: 16px;">姓名</th>
            <th style="text-align: center; font-size: 16px;">手机</th>


            <th style="text-align: center; font-size: 16px;">含税金额</th>
            <th style="text-align: center; font-size: 16px;">发票号码</th>
            <th style="text-align: center; font-size: 16px;">发票类型</th>

            <th style="text-align: center; font-size: 16px;">开票时间</th>
            <th style="text-align: center; font-size: 16px;">支付方式</th>

            <th style="text-align: center; font-size: 16px;width:24%">操作</th>
        </tr>
        </thead>
        <tbody>
        {foreach $list as $val}
        <tr>
            {if $Think.session.usertype=="0"}
            <td style="text-align: center;">{$val.pay_id}</td>
            {/if}
            <td style="text-align: center;">{$val.community_name}</td>
            <td style="text-align: center;">{$val.address}</td>
            <td style="text-align: center;">{$val.owner_name}</td>
            <td style="text-align: center;">{$val.owner_phone}</td>
            <td style="text-align: center;">￥{$val.pay_money}</td>
            <td style="text-align: center;">{$val.invoiceNum}</td>

            <td style="text-align: center;">
                {if $val.invoice_type == '1'}
                蓝票
                {elseif $val.invoice_type == '2'}
                <span style="color:red">红票</span>
                {else}
                {/if}
            </td>

            <td style="text-align: center;">{$val.invoice_time}</td>
            <td style="text-align: center;">
                {if $val.ctype == '1'}
                线下
                {elseif $val.ctype == '2'}
                线上
                {else}
                {/if}
            </td>
            <td class="td-manage" style="text-align: center;">

                {if $val.invoice_type=="1"}
                <button class="layui-btn" onclick="x_admin_show('查看发票','{:url(\'CheckInvoice\')}?id={$val.id}',900,700)">查看</button>
                {/if}
                {if $val.invoice_type=="2"}
                <button class="layui-btn" onclick="x_admin_show('查看发票','{:url(\'CheckInvoiceRed\')}?id={$val.id}',900,700)">查看</button>
                {/if}

                <button class="layui-btn  layui-btn-warm" onclick="x_admin_show('账单详情','{:url(\'billinfo\')}?id={$val.id}',900,700)">账单</button>




                {if $val.invoice_type == 1}
                <button class="layui-btn  layui-btn-normal" onclick="x_admin_show('交付','{:url(\'delivery\')}?id={$val.id}',600,400)">交付</button>

                <button class="layui-btn  layui-btn-danger" onclick="x_admin_show('冲红','{:url(\'cancellation\')}?id={$val.id}',600,400)">冲红</button>
                {/if}

            </td>
        </tr>
        {/foreach}
        </tbody>
    </table>
    <div class="page">
        <div>
            {$invoicelist->render()}
        </div>
    </div>

</div>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
            ,type: 'datetime'
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
            ,type: 'datetime'
        });
    });
    function cancellation(){
        layer.confirm('冲红后无法恢复，确定冲红吗', function(){
            $.post('{:url("billDel")}', { id: str}, function(r){
                if (r.info) {
                    layer.msg(r.info)
                    location.reload()
                }else{
                    layer.msg(r.error)
                    location.reload()
                }
            })
        })
    }
    //批量导出
    function invoiceExportExcel(exporta,exportb){

        var url = "{:url('invoiceExportExcel')}?export=" + exporta+"&exportb=" + exportb
        console.log(url);
        layer.open({
            type: 2,
            title: '批量导出发票',
            shadeClose: true,
            shade: 0.8,
            area: ['80%', '95%'],
            content: url //iframe的url
        });
    }

</script>
<!-- 多条件查询 -->

<script>var _hmt = _hmt || []; (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>
</body>

</html>